import cv2
import numpy as np

import config

x = 3800
y = 2000
width = 1000
height = 600


def write_image(i, out_path):
    print("%02d.npy" % (i,))
    file = config.RADAR_MATRIX_PATH + "%02d.npy" % (i,)
    data = np.load(file)

    block = data[y:y + height, x:x + width]

    image = np.clip(block, 0, None)
    image = image / 4
    image = image.astype(np.ubyte)

    path = out_path + "%02d.png" % (i,)
    cv2.imwrite(path, image)

    np.save(out_path + "%02d.npy" % (i,), block)


if __name__ == '__main__':
    for i in range(72):
        write_image(i, '/media/develop/data/cloud/image/blocks/')
